/**********************************************************
 * CheckProgramDirectories.java
 * Created by ankur
 * Last modified Date: Aug 5, 2008 11:37:55 AM by ankur
 * Version : 0.1
 * Copyright (c) 2008 - 2008 cyberThink Infotech Pvt. Ltd., All rights reserved.
 **********************************************************/

package com.printeverywhere.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.ServletRequestAware;

import com.printeverywhere.util.AdminConstants;
import com.printeverywhere.util.FileUtil;

// TODO: Auto-generated Javadoc
/**
 * The Action Class for CheckProgramDirectories.
 * This class get the real path of files on server and calls FileUtil.showDir()
 *   
 */
public class CheckProgramDirectories extends AdminSystemTools implements ServletRequestAware{

	/** Logger for this class. */
	private static final Logger logger = Logger.getLogger(CheckProgramDirectories.class);

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/** The request. */
	private HttpServletRequest request;

	/** The dir list. */
	List<String> dirList;

	/**
	 * Gets the dir list.
	 *
	 * @return the dir list
	 */
	public List<String> getDirList() {
		return dirList;
	}

	/**
	 * Sets the dir list.
	 *
	 * @param dirList the new dir list
	 */
	public void setDirList(List<String> dirList) {
		this.dirList = dirList;
	}

	/**
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	public String execute() throws Exception{
		if (logger.isDebugEnabled()) {
			logger.debug("execute() - start"); //$NON-NLS-1$
		}

		dirList=new ArrayList<String>();
		FileUtil.showDir(request.getRealPath(AdminConstants.NONE), dirList);

		if (logger.isDebugEnabled()) {
			logger.debug("execute() - end"); //$NON-NLS-1$
		}
		return SUCCESS;
	}

	/* (non-Javadoc)
	 * @see org.apache.struts2.interceptor.ServletRequestAware#setServletRequest(javax.servlet.http.HttpServletRequest)
	 */
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	/**
	 * Gets the request.
	 *
	 * @return the request
	 */
	public HttpServletRequest getRequest() {
		return request;
	}

	/**
	 * Sets the request.
	 *
	 * @param request the new request
	 */
	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}
}